import React from 'react';

import Constants from '../../common/Constants';
import CommonSendFetchAction from '../common/CommonSendFetchAction';

//获取推荐我的新闻数
export default class NewsRequestMyNewsNumAction extends CommonSendFetchAction {
  constructor(props) {
    super(props);

    this.moduleType = Constants.MODULE_TYPE.NEWS;
    this.name = "NewsRequestMyNewsNumAction";
  }

  _dealFinishSucess(data, response) {
    var number = 0;
    if (this.data.type==='news') {
      if (data.unread_comment) {
        number+=data.unread_comment;
      }
    }else{
      if (data.unread_activity) {
        number+=data.unread_activity;
      }
      if (data.unread_comment) {
        number+=data.unread_comment;
      }
      if (data.unread_step) {
        number+=data.unread_step;
      }
      if (data.unread_system) {
        number+=data.unread_activity;
      }
    }
    
    let detail = "";
    if(data && data.detail != undefined) {
      detail = data.detail;
    }
    this.caller.setState({
      viewStatus:response.status,
      isResponeUpdate:true,
      statusText:detail,
      datanum:data,
      myNewsCommentsNum:number,
      updateAction:{name:this.name}
    })
  }
}
